From c70026c4461ed00da22e27e62408a0617ecd66c2 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Sat, 28 Oct 2006 18:08:43 +0100 Subject: [PATCH] Allow domain config file to specify credit-scheduler parameters. Imported from xen-unstable 11864:babae8ac84b95ff4fbc1cfe4ac27c59ceaba7e38, with conflict resolution by Ewan Mellor. Signed-off-by: Masami Watanabe --- tools/python/xen/xend/XendConfig.py | 3 ++- tools/python/xen/xend/XendDomain.py | 3 +++ tools/python/xen/xend/XendDomainInfo.py | 9 ++++++++- tools/python/xen/xm/create.py | 12 +++++++++--- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py index 0787ebd79f..a911a642fe 100644 --- a/tools/python/xen/xend/XendConfig.py +++ b/tools/python/xen/xend/XendConfig.py @@ -239,7 +239,8 @@ DEFAULT_CONFIGURATION = ( ('on_xend_stop', lambda info: 'ignore'), ('cpus', lambda info: []), - ('cpu_weight', lambda info: 1.0), + ('cpu_cap', lambda info: 0), + ('cpu_weight', lambda info: 256), ('vcpus', lambda info: DEFAULT_VCPUS(info)), ('online_vcpus', lambda info: info['vcpus']), ('max_vcpu_id', lambda info: info['vcpus']-1), diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index a460f2e0c3..99a2c12e83 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -772,6 +772,9 @@ class XendDomain: try: dominfo = XendDomainInfo.create(config) self._add_domain(dominfo) + self.domain_sched_credit_set(dominfo.getDomid(), + dominfo.getWeight(), + dominfo.getCap()) return dominfo finally: self.domains_lock.release() diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 26dc09b737..73c8bb9a4d 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -79,7 +79,8 @@ ROUNDTRIPPING_CONFIG_ENTRIES = [ ('uuid', str), ('vcpus', int), ('vcpu_avail', int), - ('cpu_weight', float), + ('cpu_cap', int), + ('cpu_weight', int), ('memory', int), ('shadow_memory', int), ('maxmem', int), @@ -828,6 +829,12 @@ class XendDomainInfo: def getResume(self): return "%s" % self.info['resume'] + def getCap(self): + return self.info['cpu_cap'] + + def getWeight(self): + return self.info['cpu_weight'] + def setResume(self, state): self.info['resume'] = state diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py index 67bc9f3602..eadd79891a 100644 --- a/tools/python/xen/xm/create.py +++ b/tools/python/xen/xm/create.py @@ -189,10 +189,14 @@ gopts.var('vcpus', val='VCPUS', fn=set_int, default=1, use="# of Virtual CPUS in domain.") +gopts.var('cpu_cap', val='CAP', + fn=set_int, default=None, + use="""Set the maximum amount of cpu. + CAP is a percentage that fixes the maximum amount of cpu.""") + gopts.var('cpu_weight', val='WEIGHT', - fn=set_float, default=None, - use="""Set the new domain's cpu weight. - WEIGHT is a float that controls the domain's share of the cpu.""") + fn=set_int, default=None, + use="""Set the cpu time ratio to be allocated to the domain.""") gopts.var('restart', val='onreboot|always|never', fn=set_value, default=None, @@ -705,6 +709,8 @@ def make_config(vals): config.append(['cpu', vals.cpu]) if vals.cpus is not None: config.append(['cpus', vals.cpus]) + if vals.cpu_cap is not None: + config.append(['cpu_cap', vals.cpu_cap]) if vals.cpu_weight is not None: config.append(['cpu_weight', vals.cpu_weight]) if vals.blkif: -- 2.30.2